package pingan.com.quarter_hour.adpater;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.facebook.drawee.view.SimpleDraweeView;

import java.util.List;

import pingan.com.quarter_hour.R;
import pingan.com.quarter_hour.bean.HotVideoBean;

/**
 * Created by xsj on 2018/1/15.
 */

public class HotVideoAdapter  extends RecyclerView.Adapter<HotVideoAdapter.ViewHolder>{

    private  List<HotVideoBean.DataBean> list;
    private Context context;

    public HotVideoAdapter(List<HotVideoBean.DataBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.hotvoideitem, null);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.touxiang.setImageURI(list.get(position).getUser().getIcon());
        holder.name.setText(list.get(position).getUser().getNickname());
        holder.time.setText(list.get(position).getCreateTime());
        Glide.with(context).load(list.get(position).getCover())
                .error(R.drawable.beijin)
                .into(holder.imageview);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder{

        private  SimpleDraweeView touxiang;
        private TextView name;
        private  TextView time;
        private ImageView imageview;

        public ViewHolder(View itemView) {
            super(itemView);

            touxiang = itemView.findViewById(R.id.sdv_head_image);
            name = itemView.findViewById(R.id.name);
            time = itemView.findViewById(R.id.time);
            imageview = itemView.findViewById(R.id.imageview);

        }
    }
}
